<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp/taglibs.jsp"%>
	<style type="text/css">
		th,td{
			height:40px;
			line-height: 40px;
		}
		
		#backupBtn .l-btn-text{
			font-size: 18px;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$("#schemaTablesSelect").show();			
		})
		
		function selectBackupType(obj){
			if($(obj).val() == 0){
				$("#schemaTablesSelect").show();
				$("#tableNameCommbox").combobox("enableValidation");
			}else{
				$("#schemaTablesSelect").hide();
				$("#tableNameCommbox").combobox("disableValidation");
			}
		}
		
		function submitBackupForm(){
			if($('#dataBaseBackupForm').form('validate')){
				$('#backupBtn').linkbutton('disable');
				$.messager.progress({
					msg : "正在努力备份中，请稍后...",
					text : "",
					interval : 100
				});
				$.ajax({
					type: "POST",
					timeout:20000,
					url:  $('#dataBaseBackupForm').attr("action"),
					data:$("#dataBaseBackupForm").serialize(),
					success: function(data,res){
					alert(data);
						var msn = msn||i18n[data];
						$.messager.progress('close');
						if(msn == undefined){
							$.messager.alert('提示',i18n.serverError,'info');
						}else if(msn)	{	
							$.messager.alert('提示',msn,'info',function(){});
						}
						$('#backupBtn').linkbutton('enable');
						if(successcallback != undefined){
							successcallback();
						}
					},
					error: function(res){
						$.messager.progress('close');
						var data = $.trim(res.responseText);
						if(data == "unLogin"){
							var msn = ''||i18n[''];
							msn = msn||i18n[data];
							if(msn != undefined){
								$.messager.alert('提示',msn,'info',function(){top.location=paramObj.ctx+'/login.jsp';});
								return ;
							}
						}
						$.messager.alert('提示',i18n.requestError,'error');
						$('#backupBtn').linkbutton('enable');
						if(failurecallback != undefined){
							failurecallback();
						}
					}
				});
			}
		}
	</script>
	<form name="dataBaseBackupForm" id="dataBaseBackupForm" method="post" action="${ctx}/business/dbmanage/backup" >
	<table class="infoTable" style="margin-top:20px;">
		<tbody>
			<tr>
				<th>操作提示：</th>
				<td>
					<ul>
						<li>数据备份功能根据你的选择备份全部数据或指定数据，导出的数据文件可用“数据恢复”功能或 phpMyAdmin 导入</li>
						<li>建议定期备份数据库</li>
					</ul>
				</td>
			</tr>
			<tr>
				<th>备份方式：</th>
				<td>
					<input type="radio" value="0" checked="checked" onclick="selectBackupType(this)" name="backupType"/> 备份选定的表
					<input type="radio" value="1" onclick="selectBackupType(this)" name="backupType"/> 备份全部数据
				</td>
			</tr>
			<tr id="schemaTablesSelect">
				<th>
					选择备份表：
				</th>
				<td>
					    <input id="tableNameCommbox" style="width:540px;height:34px;font-size: 14px;color:green;" class="easyui-combobox" name="schemaTables" 
					    	data-options="url:'${ctx}/business/dbmanage/allTableNames',required:true,
							method:'get',
							valueField:'tableName',
							textField:'tableName',
							multiple:true,editable:false">
				</td>
			</tr>
			<tr>
				<th>备份文件名称：</th>
				<td>
					<input name="backUpFileAlias" class="easyui-validatebox" style="width:540px;height:34px;font-size: 14px;color:green;font-weight: bold" prompt="请输入备份文件名称" data-options="required:true" size="24" maxlength="64"/>
					<a href="javascript:void(0);" id="backupBtn" onclick="submitBackupForm();" style="width:100px;height:34px;" class="easyui-linkbutton">开始备份</a>
				</td>
			</tr>
		</tbody>
	</table>
	</form>